<template>
  <div class="warp">
    <div class="mobile-search w-full shadow-lg h-12 yu-bgColor-one-only  mb-1 flex items-center fixed z-100">
      <div class="expand ml-2 w-1/5">
        <van-icon class-prefix="i-mdi-format-indent-decrease" class="yu-color-text"  @click="showPopup"></van-icon>
      </div>
      <div class="search w-3/5">
        <van-search v-model="searchValue" shape="round" disabled background="transparent" placeholder="请输入搜索关键词" />
      </div>
      <div class="w-1/5 text-center yu-color-text">
        <div v-if="token" @click="jumpHome">
          <img  class="w-10 h-10 rounded-full" :src="store.getUserInfoGetters.avatarUrl" alt="">
        </div>
        <div v-else @click="jumpHome">登录</div>
      </div>
    </div>
    <div class="h-12"></div>
    <div class="h-10 yu-bgColor-one-only flex items-center yu-color-text text-xl" @click="back" v-if="!isContains.includes(route.matched[1].path)">
      <span class="i-mdi-backburger ml-2 mr-2"></span>
      <span>返回</span>
    </div>
  </div>
</template>

<script setup>
import {ref} from "vue";
import { useStore } from "@/store/index"
import {useRoute, useRouter} from "vue-router"

// 假的搜索框
const searchValue = ref()
const store = useStore()
const route = useRoute()
const router = useRouter()
// token
const token = ref(store.token)
const showPopup = () => {
  store.popupExpand = true
}

// 设置不显示返回按钮的白名单
const isContains = ref(['/discover', '/mobile-details-song'])

// 跳转到主页
const jumpHome = () => {
  let query
  if (store.getUserInfoGetters.userId) {
    query = { id: store.getUserInfoGetters.userId }
  }
  router.push({
    path: '/user/mobile-homepage',
    query
  })
}

// 返回上一层
const back = () => {
   router.back()
}
</script>

<style scoped>

</style>
